package cn.kshost.zqyg.manager.service.impl;

import cn.kshost.zqyg.manager.mapper.SysRoleMapper;
import cn.kshost.zqyg.manager.service.SysRoleService;
import cn.kshost.zqyg.model.dto.system.SysRoleDto;
import cn.kshost.zqyg.model.entity.system.SysRole;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.TimeZone;

@Service
public class SysRoleServiceImpl implements SysRoleService {

    @Autowired
    private SysRoleMapper sysRoleMapper;



    @Override
    public PageInfo<SysRole> findByPage(SysRoleDto sysRoleDto, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
       List<SysRole> sysRoleList =  sysRoleMapper.selectByPage(sysRoleDto);
       PageInfo<SysRole> pageInfo = new PageInfo<>(sysRoleList);
       return pageInfo;

    }

    @Override
    public void saveSysRole(SysRole sysRole) {
        System.out.println("sysRole = " + sysRole);
        sysRoleMapper.insertRole(sysRole);
            }

    @Override
    public void modifySysRole(SysRole sysRole) {
        sysRoleMapper.updateSysRole(sysRole);
    }

    @Override
    public void removeSysRole(SysRole sysRole) {
        sysRoleMapper.deleteSysRole(sysRole);
    }

    @Override
    public List<SysRole> getAllRoles() {
       return sysRoleMapper.selectAllRole();
    }
}
